import csv
import requests, unittest
from ddt import ddt, data

@ddt
class Login(unittest.TestCase):
    def setUp(self) -> None:
        print('start case')

    def tearDown(self) -> None:
        print('end case')

    filePath = 'data.csv'

    def get_csv(self, filePath):
        datalist = []
        with open(filePath, 'r') as f:
            datas = csv.reader(f)
            for i in datas:
                datalist.append(i)
        datalist.pop(0)
        return datalist

    @data(*get_csv(None, filePath))
    def test_01_login(self, csv_data):
        username, password = csv_data
        url = 'http://10.59.9.14:7003/api/public/login'
        data = {"username": username, "password": password}
        login = requests.post(url=url, json=data)
        print(login.json())


if __name__ == '__main__':
    unittest.main()
